﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Shop.Home.Repositories;
using Shop.Wares.Models;
using PetaPoco;

namespace Shop.Home.Services
{
    public class HomeAccess
    {
        Repositories.HomeAccess dal = new Repositories.HomeAccess();
        /// <summary>
        /// 获取一个类别下销售量前几的商品信息
        /// </summary>
        /// <param name="Top">前几？</param>
        /// <param name="CID">类别ID</param>
        /// <returns></returns>
        public IList<Wares.Models.Wares> GetTopWInfo(int Top, int CID)
        {
            return dal.GetTopWInfo(Top,CID);
        }
        /// <summary>
        /// 获取相应类别最新的商品
        /// </summary>
        /// <param name="Top"></param>
        /// <param name="CID"></param>
        /// <param name="SCID"></param>
        /// <returns></returns>
        public IList<Wares.Models.Wares> GetNowWInfo(int Top, int CID, int SCID)
        {
            return dal.GetNowWInfo(Top, CID, SCID);
        }
        /// <summary>
        /// 前台获取类别内商品信息
        /// </summary>
        /// <param name="page">第几页</param>
        /// <param name="itemsPerPage">每页多少行</param>
        /// <param name="CID">类别ID</param>
        /// <param name="SCID">子类别ID</param>
        /// <param name="WName">商品名</param>
        /// <param name="OrderBy">排序字段名</param>
        /// <param name="Lift">升降序标志，0升序，1降序DESC</param>
        /// <returns></returns>
        public Page<Shop.Wares.Models.Wares> GetHomeSerchWaresInfo(long page, long itemsPerPage, int CID, int SCID, string WName, string OrderBy, int Lift)
        {
            return dal.GetHomeSerchWaresInfo(page,itemsPerPage,CID,SCID,WName,OrderBy,Lift);
        }

        /// <summary>
        /// 根据CID获取类别信息
        /// </summary>
        /// <param name="CID"></param>
        /// <returns></returns>
        public Shop.Wares.Models.WaresCategory GetWCInfo(int CID)
        {
            return dal.GetWCInfo(CID);
        }
        /// <summary>
        /// 根据SCID获取类别信息
        /// </summary>
        /// <param name="SCID"></param>
        /// <returns></returns>
        public Shop.Wares.Models.SonWaresCategory GetSWCInfo(int SCID)
        {
            return dal.GetSWCInfo(SCID);
        }
        /// <summary>
        /// 根据WID获取商品信息
        /// </summary>
        /// <param name="WID">商品ID</param>
        /// <returns></returns>
        public Shop.Wares.Models.AnyWares GetWInfo(int WID)
        {
            return dal.GetWInfo(WID);
        }
    }
}
